package com.example.administrator.mymusic;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2013/1/2.
 */
public class ShangFragment extends Fragment implements View.OnClickListener {
    private ImageView imageViewBD, imageViewGC;
    private TextView tvBiaoTi;
    private List<ImageView> imageViewList;

    public List<ImageView> getImageViewList() {
        return imageViewList;
    }

    public TextView getTvBiaoTi() {
        return tvBiaoTi;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_shang, null);
        imageViewList = new ArrayList<>();
        tvBiaoTi = (TextView) view.findViewById(R.id.tv_fr_shang_biaoti);
        imageViewBD = (ImageView) view.findViewById(R.id.iv_fr_shang_bd);
        imageViewGC = (ImageView) view.findViewById(R.id.iv_fr_shang_gc);
        imageViewList.add(imageViewBD);
        imageViewList.add(imageViewGC);
        imageViewBD.setOnClickListener(this);
        imageViewGC.setOnClickListener(this);
        return view;
    }

    @Override
    public void onClick(View v) {
        ZhongFragment zhongFragment = (ZhongFragment) getActivity().getSupportFragmentManager()
                .findFragmentByTag("zhongFragment");
        ViewPager viewPager = zhongFragment.getViewPager();
        switch (v.getId()) {
            case R.id.iv_fr_shang_bd:
                viewPager.setCurrentItem(0);
                break;
            case R.id.iv_fr_shang_gc:
                viewPager.setCurrentItem(1);
                break;
        }
    }
}
